<?php

/**
 * 
 * @author Youssef Driouach
 *
 */
class Application_Model_Tool_ObjectUrl{
	
	/**
	 * delete the special char from the $chaine
	 * @param unknown_type $chaine
	 * @return mixed
	 */
	public static function suppr_accents($chaine) {
		$accents = array(' ','À','Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ò','Ó','Ô','Õ','Ö','Ù','Ú','Û','Ü','Ý','à','á','â','ã','ä','å','ç','è','é','ê','ë','ì','í','î','ï','ð','ò','ó','ô','õ','ö','ù','ú','û','ü','ý','ÿ');
		$sans = array('_','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','o','o','o','o','o','u','u','u','u','y','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','o','o','o','o','o','o','u','u','u','u','y','y');
		return str_replace($accents, $sans, $chaine);
	}
	
	/**
	 * transform the name of the object to an url.
	 * @param string $name
	 * @return mixed
	 */
	public static function getObjectNameUrl($name){
		return preg_replace("#[^a-z_A-Z0-9]#", "", strtolower(Application_Model_Tool_ObjectUrl::suppr_accents($name)));
	}
	
}